// 公告通知管理模块api
import { axios } from '@/utils/request'
// 获取系统公告分页数据
function getSysAnnouncePageData (query) {
  return axios({
    url: '/user-service/notice/list',
    method: 'get',
    params: query
  })
}

// 删除系统公告
function deleteSysAnnounceData (query) {
  return axios({
    url: '/user-service/notice',
    method: 'delete',
    params: query
  })
}

// 撤回系统公告
function withdrawSysAnnounceData (query) {
  return axios({
    url: '/user-service/notice/withdraw',
    method: 'put',
    params: query
  })
}

// 获取用户下拉框
function getUserSelect (query) {
  return axios({
    url: '/user-service/user/select',
    method: 'get',
    params: query
  })
}
// 测试公告
function testAnnounceData (data) {
  return axios({
    url: '/user-service/notice/test',
    method: 'post',
    data
  })
}
// 发布公告
function publishAnnounceData (query) {
  return axios({
    url: '/user-service/notice/publish',
    method: 'post',
    params: query
  })
}

// 获取用户分页数据
function getUserPageData (query) {
  console.log(query, 'query')
  return axios({
    url: '/user-service/user/list',
    method: 'get',
    params: query
  })
}

// 获取角色列表
function getRoleAllData (query) {
  return axios({
    url: '/user-service/role/list',
    method: 'get',
    query
  })
}

// 获取公告详情（根据公告ID查询公告信息）
function getAnnounceDataById (query) {
  return axios({
    url: '/user-service/notice/info',
    method: 'get',
    params: query
  })
}

// 新建系统公告
function createAnnounceData (data) {
  return axios({
    url: '/user-service/notice/create',
    method: 'post',
    data
  })
}
// 编辑系统公告
function editAnnounceData (data) {
  return axios({
    url: '/user-service/notice/edit',
    method: 'put',
    data
  })
}

// 判断是否弹出弹窗提示
function isAlertPopup () {
  return axios({
    url: '/user-service/notice/popup',
    method: 'get'
  })
}

// 获取系统更新消息提示
function getSysUpdateNews () {
  return axios({
    url: '/user-service/notice/upgradeMaintenance',
    method: 'get'
  })
}
// 获取系统中心列表信息公告
function getSysAnnounceList () {
  return axios({
    url: '/user-service/notice/messageCenter',
    method: 'get'
  })
}
// 获取系统中心列表平台历史版本
function getSysHistoryVersion () {
  return axios({
    url: '/user-service/notice/historyVersion',
    method: 'get'
  })
}
// 清除所有系统公告（未读=》已读）
function  updateAllSysAnnounceState () {
  return axios({
    url: '/user-service/notice/clearAllUnread',
    method: 'post'
  })
}
// 清除单个系统公告（未读=》已读）
function  updateSingleSysAnnounceState (query) {
  return axios({
    url: '/user-service/notice/clearOneUnread',
    method: 'post',
    params: query
  })
}

export default {
  getSysAnnouncePageData,
  deleteSysAnnounceData,
  withdrawSysAnnounceData,
  getRoleAllData,
  getUserPageData,
  getUserSelect,
  testAnnounceData,
  publishAnnounceData,
  createAnnounceData,
  editAnnounceData,
  getSysAnnounceList,
  getSysHistoryVersion,
  updateAllSysAnnounceState,
  updateSingleSysAnnounceState,
  getSysUpdateNews,
  isAlertPopup,
  getAnnounceDataById
}
